#include "get_time.h"

string get_time()
{
 long ts;
 itime ltime;
 struct tm *timenow;
 ts=time(NULL);
 timenow=localtime(&ts);
 ltime.y=timenow->tm_year+1900;
 ltime.m=timenow->tm_mon+1;
 ltime.d=timenow->tm_mday;
 ltime.h=timenow->tm_hour;
 ltime.n=timenow->tm_min;
 ltime.s=timenow->tm_sec;
 char year[4];
 char month[2];
 char day[2];
 char hour[2];
 char minute[2];
 char sec[2];
 sprintf(year,"%d",ltime.y);
 sprintf(month,"%d",ltime.m);
 sprintf(day,"%d",ltime.d);
 sprintf(hour,"%d",ltime.h);
 sprintf(minute,"%d",ltime.n);
 sprintf(sec,"%d",ltime.s);

 string syear(year);
 string smonth(month);
 string sday(day);
 string shour(hour);
 string sminute(minute);
 string ssec(sec);
 if(smonth.length()==1)
  smonth="0"+smonth;
 if(sday.length()==1)
  sday="0"+sday;
 if(shour.length()==1)
  shour="0"+shour;
 if(sminute.length()==1)
  sminute="0"+sminute;
 if(ssec.length()==1)
  ssec="0"+ssec;
 string sltime=syear+smonth+sday+shour+sminute+ssec; 
 return sltime;
};

